/*
 * Author Peter Mosher
 */
package tests;

import static org.junit.Assert.*;

import model.LMA;
import model.Scheduler;
import model.Users;
import model.Volunteer;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import util.Stringer;

	/**
	 * Tests to make sure that the non-getter/setter 
	 * methods are running properly for Users class.
	 * @author Peter Mosher
	 * @author Andy Johnson
	 * @author Kyle Richardson
	 */
	public class UsersTest {
		Volunteer tim;
		LMA rose;
		Scheduler tommy;
		Users people;
	
	/**
	 * Sets up variables for the tests.
	 * @throws Exception
	 */
	@Before
	public void setUp() throws Exception {
		tim = new Volunteer(Stringer.getString(85), 
				Stringer.getString(86), 
				Stringer.getString(87),
				null, null, null, null);
		rose = new LMA(Stringer.getString(88), 
				Stringer.getString(89), 
				Stringer.getString(90),
				null, null, null, null, null, null);
		people = new Users();
		tommy = new Scheduler(Stringer.getString(91), 
				Stringer.getString(92), 
				Stringer.getString(93),
				null, null, null, null, null, null);
	}
	
	/**
	 * Tests the removal of a user.
	 * 
	 * @author Andy Johnson
	 */
	@Test
	public void testRemoveUser() {
		assertTrue(people.isEmpty());
		assertTrue(people.addLMA(rose));
		assertFalse(people.isEmpty());
		assertTrue(people.removeUser(rose));
	}

	/**
	 * Tests finding a User by name.
	 */
	@Test
	public void testFindByName()
	{
		people.addUser(tim);

		assertTrue(people.findUserByName(
				Stringer.getString(94))==null);
		assertTrue(people.findUserByName(
				Stringer.getString(95))!=null);
		assertTrue(people.findUserByName(
				Stringer.getString(96))==null);
	}
	
	/**
	 * Tests to make sure that the program can find
	 * a Volunteer by name. 
	 * Adds a Volunteer and tests whether this user
	 * is the same user that is stored.
	 * 
	 * @author Kyle Richardson
	 */
	@Test
	public void testFindVolByName() {
		people.addVolunteer(tim);
		people.addLMA(rose);
		assertEquals(people.findVolByName(
				Stringer.getString(97)),tim);
		assertEquals(people.findVolByName(
				Stringer.getString(98)), null);
	}

	/**
	 * Tests to make sure that the program can find
	 * a Scheduler by name.
	 */
	@Test
	public void testFindSchByName() {
		people.addScheduler(tommy);
		people.addVolunteer(tim);
		assertEquals(people.findSchByName(
				Stringer.getString(99)), tommy);
		assertEquals(people.findSchByName(
				Stringer.getString(100)), null);
	}

	/**
	 * Tests to make sure that the program can find a 
	 * Land Management Agency User by name.
	 */
	@Test
	public void testFindLMAByName() {
		people.addLMA(rose);
		people.addVolunteer(tim);
		assertEquals(people.findLMAByName(
				Stringer.getString(101)), rose);
		assertEquals(people.findSchByName(
				Stringer.getString(102)), null);
	}

	/**
	 * Tests to make sure that the system can add a
	 * Land Management Agency User to the list of users.
	 */
	@Test
	public void testAddLMA() {
		people.addLMA(rose);
		people.addVolunteer(tim);
		people.addScheduler(tommy);
		assertTrue(people.getLMAs().contains(rose));
		assertFalse(people.getLMAs().contains(tim));
		assertFalse(people.getLMAs().contains(tommy));
	}

	/**
	 * Tests to see if this scheduler added is the same
	 * one that is stored. It tests to make sure that
	 * Schedulers are added correctly.
	 */
	@Test
	public void testAddSheduler() {
		people.addScheduler(tommy);
		assertEquals(people.getScheduler(), tommy);
	}

	/**
	 * Tests to make sure that Volunteers are added 
	 * correctly. Adds someone who is not a Volunteer to
	 * see if the program recognizes that the user is not
	 * a Volunteer.
	 */
	@Test
	public void testAddVolunteer() {
		people.addLMA(rose);
		people.addVolunteer(tim);
		people.addScheduler(tommy);
		assertFalse(people.getVolunteers().contains(rose));
		assertTrue(people.getVolunteers().contains(tim));
		assertFalse(people.getVolunteers().contains(tommy));
	}

}
